import { Alert } from "antd";
import "./index.less";
import { AlertProps } from "antd/lib";

type CustomAlertProps = AlertProps & {
  type?: "success" | "info" | "warning" | "error";
  showIcon: boolean;
  icon: string;
  description: string;
};
const CustomAlert: React.FC<CustomAlertProps> = (props) => {
  let className;
  switch (props.type) {
    case "success":
      className = "success-alert";
      break;
    case "info":
      className = "info-alert";
      break;
    case "warning":
      className = "warning-alert";
      break;
    case "error":
      className = "error-alert";
      break;
    default:
      className = "default-alert";
  }
  return (
    <div className={`custom-alert`}>
      <Alert
        {...props}
        className={className}
        // onClick={() => {
        //   history.push("/identity");
        // }}
        message={props.message}
        type={props.type}
        showIcon={props.showIcon}
        icon={<img src={props.icon} alt="SVG Image" />}
        description={
          <div dangerouslySetInnerHTML={{ __html: props.description }} />
        }
      />
    </div>
  );
};
export default CustomAlert;
